part of '../repository.dart';

class _WebPurchasedSubscriptionInfoDtoFactory {
  const _WebPurchasedSubscriptionInfoDtoFactory._internal();

  static const _instance = _WebPurchasedSubscriptionInfoDtoFactory._internal();

  factory _WebPurchasedSubscriptionInfoDtoFactory() {
    return _instance;
  }

  _WebPurchasedSubscriptionInfoDto fromJson(Map<String, dynamic> json) {
    final paymentSystem = json[_kWebPurchasedSubscriptionInfoPaymentSystemKey] as String;

    if (paymentSystem == _kWebPurchasedSubscriptionInfoYookassaPaymentSystemValue) {
      return _YookassaPurchasedSubscriptionInfoDto.fromJson(json);
    }

    throw UnimplementedError();
  }

  _WebPurchasedSubscriptionInfoDto fromEntity(WebPurchasedSubscriptionInfo webPayment) {
    if (webPayment is YookassaPurchasedSubscriptionInfo) {
      return _YookassaPurchasedSubscriptionInfoDto.fromEntity(webPayment);
    }

    throw UnimplementedError();
  }
}
